﻿using Cysharp.Threading.Tasks;
using ShawnFramework;
using UnityEngine.UI;

public class LoginPanel : Panel
{
    public InputField inputAccount;
    public InputField inputPassword;
    public Button btnLogin;

    void Start()
    {
        // 切换游戏阶段
        Global global = Global.Instance;
        GameFlowManager flowMng = Global.Instance.FlowMng;

        NodeUtil.BindClick(btnLogin, () =>
        {
            
            flowMng.GameFlow = GameFlowEnum.Game;
            // 关闭自身面板
            Close();
            // 进度条
            PanelUtil.OpenPanelByName(Global.Instance.PanelContainer, "LoadingPanel", async (panel) =>
            {
                LoadingPanel loadingPanel = panel as LoadingPanel;
                await loadingPanel.UpdateProgress(0f, 0f);
                await loadingPanel.UpdateProgress(0.5f, 1f);
                await AsyncUtil.WaitSecond(0.5f);
                await loadingPanel.UpdateProgress(1f, 0.4f);
            });
        });  
    }
}